package com.starblink.android.basic.sensorsdata.room

import androidx.room.TypeConverter
import com.blankj.utilcode.util.GsonUtils

class TraceConverter {

    @TypeConverter
    fun map2Str(map: Map<String, String>): String = GsonUtils.toJson(map)

    @TypeConverter
    fun str2MapStr(json: String): Map<String, String> =
        GsonUtils.fromJson(json, GsonUtils.getMapType(String::class.java, String::class.java))

    @TypeConverter
    fun list2Str(list: List<String>): String = GsonUtils.toJson(list)

    @TypeConverter
    fun str2List(json: String): List<String> =
        GsonUtils.fromJson(json, GsonUtils.getListType(String::class.java))
}